package cn.rocky.prepare;

/**
 * 6172. 严格回文的数字
 */
public class isStrictlyPalindromic {

    public static boolean isStrictlyPalindromic(int n) {
        for (int i = 2; i <= n - 2; i++) {
            String s = Integer.toString(n, i);
            int l = 0,r = s.length() - 1;
            while (l < r) {
                if (s.charAt(l) != s.charAt(r)) return false;
                l++;
                r--;
            }
        }
        return true;
    }

    public static boolean checkIsNumber(String num) {
        String reversedStr = (new StringBuilder(num + "")).reverse().toString();
        return (num + "").equals(reversedStr);
    }

    public static void main(String[] args) {
        // 1001 100 1001 100
        // 18 10010
        System.out.println(isStrictlyPalindromic(4)); //
        System.out.println(isStrictlyPalindromic(5)); //101
        System.out.println(isStrictlyPalindromic(6)); //110
        System.out.println(isStrictlyPalindromic(9)); //1001
        System.out.println(isStrictlyPalindromic(31));// 11111 -> 1011
        System.out.println(isStrictlyPalindromic(16));
    }
}
